package com.dongchedi.utils;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dongchedi.entity.CustomerLogin;
import com.dongchedi.utils.constant.ColorConstant;
import com.dongchedi.utils.constant.RedisConstantKey;
import com.dongchedi.utils.page.PageRequest;
import com.dongchedi.utils.page.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import javax.xml.crypto.Data;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Date;
import java.util.List;
/**
 * @author leibidong
 * @description测试
 * @date 2021/6/25
 */
public class test {
    @Autowired
    RedisTemplate<String,Object> redisTemplate;
    public static void main(String[] args) {
//        PageRequest pageRequest=new PageRequest(1,2);
//        PageResult pageResult =findLoginService.query(pageRequest);
//        List<CustomerLogin> list= (List<CustomerLogin>) pageResult.getContent();
//        String s= ResultMessage.getListJSONString(200,"成功",list);
//        return s;
//        Timestamp d = new Timestamp(System.currentTimeMillis());
//        Date date = new Date();
////        Timestamp nousedate = new Timestamp(date.getTime());
////        System.out.println(nousedate);
        //System.out.println(OrderEncodingUtil.getOrderCode(1).length());
//        System.out.println(ColorConstant.BACK.getIndexByName("魂动红"));
//        System.out.println(ColorConstant.BACK.getNameByIndex(12));
        //System.out.println(CheckUtil.checkLoginName("1234220"));
       // System.out.println(CheckUtil.checkPassword("11"));
     new test().tt();
    }

    @GetMapping("/test")
    public String tt(){
        LocalDate today = LocalDate.now();
        String s= RedisConstantKey.getHotsaleKey(today);
        System.out.println(redisTemplate);
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("status","ok");
        JSONArray jsonArray=new JSONArray();
        jsonArray.add(jsonObject);
        // redisTemplate.opsForValue().set("111",jsonArray.toJSONString(),1,TimeUnit.SECONDS);

        //redisTemplate.opsForValue().set("111",jsonObject,1,TimeUnit.SECONDS);
//        long len=redisTemplate.opsForSet().size(s);
//        System.out.println(s+"   "+len);
//        if(len!=0) {
//            System.out.println(1111);
//           Set<Object> set= redisTemplate.opsForSet().members(s);
//           Iterator iterator =set.iterator();
//           String name="";
//           while (iterator.hasNext()){
//               name+=iterator.next()+" ";
//           }
//            return name+redisTemplate.opsForValue().get("111");
        //}
        return (String) redisTemplate.opsForValue().get("111");
    }
}
